<template>
	<view class="container">

		<view class="update-info">
			<h3 class="title w">修改昵称</h3>
			<view class="update">
				<textarea class="textarea" placeholder="请输入新的昵称" v-model="newUsername">
				</textarea>
			</view>
		</view>


		<view class="fotter">
			<view class="add">

				<tui-button shape="circle" @click="publish" limit='1'>点击修改</tui-button>

			</view>
		</view>


		<tui-toast ref="toast"></tui-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newUsername: '',
			}
		},
		methods: {
			publish() {
				const updateData = {
					id: 1, // 用户ID
					username: this.newUsername, // 新的用户名
					passw:"123",
					notenum:"456",
					visitnum:"789",
					role:"用户",
					time:"",
					photourl:"https://images.pexels.com/photos/12508069/pexels-photo-12508069.jpeg?auto=compress&cs=tinysrgb&w=600&lazy=load"
				};

				uni.request({
					url: '/usr/update',
					method: 'PUT', 
					header: {
						'content-type': 'application/json'
					},
					data: updateData,
					success: (res) => {
						if (res.statusCode === 200) {
							// 更新成功的处理逻辑
							console.log("111")
						}
					},
					fail: (err) => {
						console.error(err);
					}
				});
			},
		}
	}
</script>

<style>
	@import url("updateInfo.css");
</style>